<template>
  <div class="row"> 范围半径（km） </div>
  <div class="row rf">

         <el-checkbox-group
    v-model="checkedCities"
    @change="handleCheckedCitiesChange"
  >
    <el-checkbox :value="10">{{ 10 }}</el-checkbox>
     <el-checkbox :value="20">{{ 20 }}</el-checkbox>
      <el-checkbox :value="50">{{ 50 }}</el-checkbox>
       <el-checkbox :value="100">{{ 100 }}</el-checkbox>
  </el-checkbox-group>
    <!-- <el-radio-group v-model="toRad" @change="updateStore('option1')">
      <el-radio :value="10">10</el-radio>
      <el-radio :value="20">20</el-radio>
      <el-radio :value="50">50</el-radio>
      <el-radio :value="100">100</el-radio>
    </el-radio-group> -->
    <el-input
      style="width: 100px; background-color: transparent"
      v-model="input"
      @change="updateStore()"
      placeholder="自定义"
    />
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useMapStoreStore } from '../../../stores/index'
const { radius, increment } = useMapStoreStore();
const store = useMapStoreStore();
import {ElMessage} from 'element-plus'
const input = ref('');
const checkedCities = ref([]);

watch(()=>checkedCities.value,(newval)=>{
  if(input.value){
      increment([...newval,input.value]);
  }else{
      increment(newval)
  }
})
// watch(()=>store.radius,(newval)=>{
//   checkedCities.value = newval;
// })
const updateStore = ()=>{
  if(isNaN(input.value)){
  ElMessage({
          message: '只能输入数字',
          type: 'warning',
          plain: true
        })
        return;
  }

  if(input.value === ''){
    increment(checkedCities.value)
    return
  }
   increment([...checkedCities.value,input.value]);
}


</script>

<style lang="scss" scoped>
.row {
  width: 100%;
  height: 50%;
  font-size: 18px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #b9eeff;
}
:deep(.el-checkbox){
  --el-checkbox-text-color:none;
  margin-right:15px;
}

.el-checkbox-group.el-checkbox {
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 8px 12px;
  margin-right: 10px;
}
.el-checkbox-group.el-checkbox.is-checked {
  background-color: #409eff;
  color: #fff;
}
.el-checkbox-group.el-checkbox.is-checked.el-checkbox__input.is-checked+.el-checkbox__label {
  color: #fff;
}
:deep(.el-input) {
  margin-bottom: 0;
}
:deep(.el-input__wrapper) {
  background-color: transparent;
  border: 1px solid #b9eeff;
  box-shadow: none;
}
:deep(.el-input__inner) {
  color: #b9eeff;
  font-size: 16px;
}
:deep(.el-input__inner::placeholder) {
  color: #b9eeff;
}
</style>